package com.zhika.zishi.customview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.zhika.zishi.R;
import com.zhika.zishi.interfaces.OtherWayInterface;

/**
 * Created by Michael on 2015/4/5.
 */
public class OtherWayView extends FrameLayout{

    private TextView wayText;

    private Button weixinButton;

    private Button sinaButton;

    private LayoutInflater inflater;

    private Context context;

    private OtherWayInterface otherWayInterface;

    public void setOtherWayInterface(OtherWayInterface otherWayInterface){
        this.otherWayInterface = otherWayInterface;
    }

    public OtherWayView(Context context){
        this(context, null);
    }
    public OtherWayView(Context context, AttributeSet attributeSet){
        this(context,attributeSet,0);
    }
    public OtherWayView(Context context, AttributeSet attributeSet, int defStyle){
        super(context,attributeSet,defStyle);
        this.context = context;
        inflater = LayoutInflater.from(context);
        initView();
    }

    private void initView(){
        View  view = inflater.inflate(R.layout.other_way_layout,this);
        wayText = (TextView) view.findViewById(R.id.other_way_text);
        weixinButton = (Button) view.findViewById(R.id.other_way_weixin_button);
        sinaButton = (Button) view.findViewById(R.id.other_way_sina_button);

        weixinButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                otherWayInterface.weixinButtonListener();
            }
        });

        sinaButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                otherWayInterface.sinaButtonListener();
             }
        });
    }

    public void setWayText(String msg){
        wayText.setText(msg);
    }
}
